package com.czb;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@EnableHystrix
@EnableHystrixDashboard
@EnableEurekaClient	// 表明自己是一个eureka client
@SpringBootApplication
@RestController
public class EurekaClientApplication {
	@Value("${server.port}")
	private String port;

	public static void main(String[] args) {
		SpringApplication.run(EurekaClientApplication.class, args);
	}

	@HystrixCommand(fallbackMethod = "showError")
	@RequestMapping("/show")
	public String show(@RequestParam String name){
		return name + ":" + port;
	}

	public String showError(String name){
		return "client error " + name;
	}
}
